/**
 * 2010(c) Copyright Oceansoft Information System Co.,LTD. All rights reserved.
 * <p>
 * Compile: JDK 1.6+
 * <p>
 * 版权所有(C)：江苏欧索软件有限公司
 * <p>
 * 公司名称：江苏欧索软件有限公司
 * <p>
 * 公司地址：中国苏州科技城青山路1号
 * <p>
 * 网址: http://www.oceansoft.com.cn
 * <p>
 * 作者: 090922(陈伟)
 * <p>
 * 文件名: com.oceansoft.mobile.econsole.modules.api.controller.ApiMattersController.java
 * <p>
 * 类产生时间: 2014-6-18 0018 下午 14:14
 * <p>
 * 负责人: 090922(陈伟)
 * <p>
 * Email:javacspring@gmail.com
 * <p>
 * 所在组 : 掌上公安应用平台
 * <p>
 * 所在部门: 开发部--手持技术部
 * <p>
 * <p>
 */
package com.oceansoft.mobile.econsole.modules.api.controller;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.oceansoft.mobile.econsole.modules.api.service.IMattersService;
import com.oceansoft.mobile.econsole.modules.api.v2.controller.ApiCaseController;
import com.oceansoft.mobile.econsole.modules.ascproject.entity.MydEvaluation;
import com.oceansoft.mobile.econsole.modules.base.controller.BaseController;
import com.oceansoft.mobile.econsole.modules.base.entity.Query;
import com.oceansoft.mobile.econsole.modules.base.entity.Result;
import com.oceansoft.mobile.econsole.modules.member.entity.WtMember;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;

import static org.springframework.web.bind.annotation.RequestMethod.GET;
import static org.springframework.web.bind.annotation.RequestMethod.POST;

/**
 * 事项中心接口
 *
 * @time: 2014-6-18 0018 下午 14:14
 * @modify 2016-08-10 事项中心接口 {@link ApiCaseController and ApiOrgController} instead
 * 咨询中心，继续使用这个接口
 */
@RestController
@RequestMapping("api/matters")
public class ApiMattersController extends BaseController {

    @Resource
    private IMattersService mattersService;


    /**
     * 加载手机客户端可申报或预约事项字典，<br>
     * 只有写字典项匹配的事项或警种才能在手机终端进行申报
     *
     * @return Result
     */
    @RequestMapping("dict/mobile/declare")
    public Result loadApplyDict() {
        HashMap<String, Object> dict = new HashMap<String, Object>(2) {
            {
                put("declare", new HashMap<String, String>() {
                    {
                        put("687a63ec-7e65-41e3-b90a-7febc72dc9a4",
                                "matters-vehicle");// 货车临时通行证
                        put("80d4c89e-69af-4978-aa1c-1d8c63d7f2e1",
                                "matters-lawyer");// 律师预约
                    }
                });
                put("appointment", new HashMap<String, String>() {
                    { // 预约警种
                        put("2", "appointment-entry-exit");// 出入境
                        put("3", "appointment-swat");// 特警
                    }
                });
            }
        };
        return new Result(dict);
    }

    /**
     * 事项中心
     *
     * @param type       -1 市局 2 分局
     * @param bureaus_id 分局id
     * @param catalog    警种
     * @param police_id  派出所id
     * @param subject    0 企业 1 个人
     * @param pageIndex  第几页
     * @param keywords   关键字
     * @param pageSize   分页大小
     * @return Result
     */
    @RequestMapping(value = "page/case", method = GET)
    public Result loadMatterByPage(
            @RequestParam(value = "type", defaultValue = "") final String type,
            @RequestParam(value = "bureausId", defaultValue = "") final String bureaus_id,
            @RequestParam(value = "catalog", defaultValue = "") final String catalog,
            @RequestParam(value = "policeId", defaultValue = "") final String police_id,
            @RequestParam(value = "subject", defaultValue = "") final String subject,
            @RequestParam(value = "pageIndex") final int pageIndex,
            @RequestParam(value = "keyword", defaultValue = "") final String keywords,
            @RequestParam("pageSize") final String pageSize) throws IOException {
        return mattersService
                .loadMattersByCondition(new HashMap<String, String>() {
                    {
                        put("UnitId", String.valueOf(bureaus_id));
                        put("UnitPcsId", String.valueOf(police_id));
                        put("CaseName", keywords);
                        put("type", type);
                        put("PageIndex", String.valueOf(pageIndex));
                        put("PageSize", String.valueOf(pageSize));
                        put("casekindtype", String.valueOf(subject));
                        put("CaseClassificationid", catalog);
                    }
                });
    }

    /**
     * 预约列表查询
     *
     * @param type    0 全部 1户籍 2出入境 3特警
     * @param keyword 关键字
     * @return Result
     */
    @RequestMapping(value = "page/appointment", method = GET)
    public Result loadAppointmentType(
            @RequestParam(value = "appointmentType") final String type,
            @RequestParam(value = "keyword", required = false, defaultValue = "") final String keyword,
            @RequestParam(value = "pageSize") final int page_size,
            @RequestParam(value = "pageIndex") final int page_index)
            throws IOException {
        return mattersService
                .loadAppointmentPage(new HashMap<String, String>() {
                    {
                        put("Category", type);
                        put("CaseName", keyword);
                        put("PageIndex", String.valueOf(page_index));
                        put("PageSize", String.valueOf(page_size));
                    }
                });
    }

    /**
     * 事项中心
     *
     * @param type       -1 市局 2 分局
     * @param bureaus_id 分局id
     * @param catalog    警种
     * @param police_id  派出所id
     * @param subject    0 个人 1 企业
     * @param pageIndex  第几页
     * @param keywords   关键字
     * @param pageSize   分页大小
     * @return Result
     */
    @RequestMapping(value = "page/case/jsonp", method = GET)
    public Result loadMatterByPageJSONP(
            @RequestParam(value = "type", defaultValue = "") final String type,
            @RequestParam(value = "bureausId", defaultValue = "") final String bureaus_id,
            @RequestParam(value = "catalog", defaultValue = "") final String catalog,
            @RequestParam(value = "policeId", defaultValue = "") final String police_id,
            @RequestParam(value = "subject", defaultValue = "") final String subject,
            @RequestParam(value = "pageIndex") final int pageIndex,
            @RequestParam(value = "keyword", defaultValue = "") final String keywords,
            @RequestParam("pageSize") final String pageSize) throws IOException {
        return mattersService
                .loadMattersByCondition(new HashMap<String, String>() {
                    {
                        put("UnitId", String.valueOf(bureaus_id));
                        put("UnitPcsId", String.valueOf(police_id));
                        put("CaseName", keywords);
                        put("type", type);
                        put("PageIndex", String.valueOf(pageIndex));
                        put("PageSize", String.valueOf(pageSize));
                        put("casekindtype", String.valueOf(subject));
                        put("CaseClassificationid", catalog);
                    }
                });
    }

    /**
     * 查询事项详细信息
     *
     * @param deptType 部门类型 -1：市局 2：分局
     * @param deptId   部门ID
     * @param matterId 事项ID
     * @return JSONP
     */
    @RequestMapping(value = "detail/{dept_type}/{dept_id}/{matter_id}", method = GET)
    public Result loadMatterDetail(@PathVariable("dept_type") int deptType,
                                   @PathVariable("dept_id") String deptId,
                                   @PathVariable("matter_id") String matterId) {
        return mattersService.loadMatterDetail(deptType, deptId, matterId);
    }

    /**
     * 加载预约指南
     *
     * @param matterId   事项编号
     * @param policeType 警种分类 1:户籍 2:出入境 3:特警
     * @return Result
     */
    @RequestMapping(value = "guide/reservation/{police_type}/{matter_id}", method = GET)
    public Result loadReservationGuide(
            @PathVariable("matter_id") String matterId,
            @PathVariable("police_type") int policeType) {
        return mattersService.loadReservationGuid(matterId, policeType);
    }

    /**
     * 货车临时通行证申报 TODO:此处接口接收参数未确认
     *
     * @return Result
     */
    @RequestMapping(value = "report/truck", method = POST)
    public Result truckReport(@RequestBody JSONObject truckReport) {
        return mattersService.submitTruckReport(truckReport);
    }

    /**
     * 律师申报 公安阶段
     *
     * @return Result
     */
    @RequestMapping(value = "report/lawyer/police", method = POST)
    public Result lawyerReportPolice(@RequestBody JSONObject lawyerReport)
            throws IOException {
        lawyerReport.put("sendtype", "1");
        lawyerReport.put("projectguid", UUID.randomUUID());
        return mattersService.submitLawyerReport(lawyerReport);
    }

    /**
     * 律师申报 其他
     *
     * @return Result
     */
    @RequestMapping(value = "report/lawyer/other", method = POST)
    public Result lawyerReportOther(@RequestBody JSONObject lawyerReport)
            throws IOException {
        lawyerReport.put("sendtype", "2");
        lawyerReport.put("projectguid", UUID.randomUUID());
        return mattersService.submitLawyerReport(lawyerReport);
    }

    /**
     * 出入境预约提交
     */
    @RequestMapping(value = "bespeak/exist", method = POST)
    public Result MatterBespeak(HttpServletRequest request) throws IOException {
        JSONObject json = new JSONObject();
        json.put("ProjectGuid", UUID.randomUUID());
        json.put("LBDW", request.getParameter("LBDW"));
        json.put("SFZH", request.getParameter("SFZH"));
        json.put("YYLX", request.getParameter("YYLX"));
        json.put("LXR", request.getParameter("LXR"));
        json.put("LXDH", request.getParameter("LXDH"));
        json.put("LXSJ", request.getParameter("LXSJ"));
        json.put("YYSJ", request.getParameter("YYSJ"));
        json.put("Area", request.getParameter("Area"));
        json.put("YYDZ", request.getParameter("YYDZ"));
        json.put("BZ", request.getParameter("BZ"));
        json.put("YYRS", request.getParameter("YYRS"));
        json.put("CreateUserid", request.getParameter("CreateUserid"));
        json.put("unitGuid", request.getParameter("unitGuid"));
        json.put("caseguid", request.getParameter("caseguid"));
        return mattersService.submitBespeakExist(json);
    }

    /**
     * 特警项目提交
     *
     * @return Result
     */
    @RequestMapping(value = "bespeak/police", method = POST)
    public Result SwatBespeak(HttpServletRequest request) throws IOException {
        JSONObject json = new JSONObject();
        json.put("ProjectGuid", UUID.randomUUID());
        json.put("CBZ", request.getParameter("CBZ"));
        json.put("ZYFZR", request.getParameter("ZYFZR"));
        json.put("SFZHM", request.getParameter("SFZHM"));
        json.put("YYLXR", request.getParameter("YYLXR"));
        json.put("YYSJ1", request.getParameter("YYSJ1"));
        json.put("Temp1", request.getParameter("Temp1"));
        json.put("Temp2", request.getParameter("Temp2"));
        json.put("LXDH", request.getParameter("LXDH"));
        json.put("HDMC", request.getParameter("HDMC"));
        json.put("HDSJ1", request.getParameter("HDSJ1"));
        json.put("HDSJ2", request.getParameter("HDSJ2"));
        json.put("HDDD", request.getParameter("HDDD"));
        json.put("HDGM", request.getParameter("HDGM"));
        json.put("CreateUserid", request.getParameter("CreateUserid"));
        json.put("unitGuid", request.getParameter("unitGuid"));
        json.put("caseguid", request.getParameter("caseguid"));
        return mattersService.submitBespeakPolice(json);
    }


    /**
     * 咨询列表、我的咨询列表
     *
     * @param query
     * @return
     * @throws IOException
     */
    @RequestMapping(value = "page/consult", method = POST)
    public Result loadConsultList(@RequestBody Query query) throws IOException {

        return mattersService.loadConsultList(new HashMap<String, String>() {
            {
                put("keywords", query.getKeywords());
                put("stattime", query.getStartTime());
                put("endtime", query.getEndTime());
                put("pageindex", String.valueOf(query.getPageNum()));
                put("pagesize", String.valueOf(query.getNumPerPage()));
                put("uid", query.getUserGuid());
                //put("ispublic", query.getUserGuid());
                //put("isanswer", query.getUserGuid());

            }
        });
    }

    /**
     * 分页我的咨询
     * @param query
     * @return
     * @throws IOException
     */
    @RequestMapping(value = "page/consults", method = POST)
    public Result loadConsultByPage(@RequestBody Query query) throws IOException {
        String userGuid = query.getUserGuid();
        WtMember member = getWxMemberSession() == null ? getMemberByGUid(userGuid) : getWxMemberSession();
        return mattersService.loadConsultByPage(query, member.getUserName());
    }


    /**
     *  我的举报
     * @param query
     * @return
     * @throws IOException
     */
    @RequestMapping(value = "page/jbconsults", method = POST)
    public Result jbloadConsultByPage(@RequestBody Query query) throws IOException {
        //微信端
       if("W".equals(query.getPt())){
/*           String userGuid = query.getUserGuid();
           WtMember member = getWxMemberSession() == null ? getMemberByGUid(userGuid) : getWxMemberSession();*/
           WtMember member = getWxMemberSession();
           return mattersService.jbloadConsultByPage(query, member.getGuid());
       }else{//APP端
           return mattersService.jbloadConsultByPage(query,query.getaUserGuid());
       }
     //   return mattersService.jbloadConsultByPage(query, "aaacf3814f8748e2aad1ab0795bad76d");
    }

    /**
     * 我的举报详细信息
     *
     * @param guid 办件编号
     * @return 我的举报详细信息
     */
    @RequestMapping(value = "info/{guid}", method = GET)
    public Result jbinfo(@PathVariable("guid") String guid)throws IOException  {
        return mattersService.jbinfo(guid);
    }

    /**
     * 根据问题id找到回答
     *
     * @param question_id 问题id
     * @return Result
     */
    @RequestMapping(value = "consult/answer/{qid}", method = GET)
    public Result loadAnswerByQid(@PathVariable("qid") String question_id)
            throws IOException {
        return mattersService.loadAnswer(question_id);
    }

    /**
     * 咨询提交
     *
     * @param question 提问实体
     * @return Result
     */
    @RequestMapping(value = "ask/question", method = POST)
    public Result submitQuestion(@RequestBody JSONObject question)
            throws IOException {
        return mattersService.askQuestion(question);
    }

    /**
     * 我的办件
     *
     * @param type       办件类型
     * @param user_id    用户ID
     * @param page_size  pageSize
     * @param page_index 当前页
     * @return Result
     */
    @RequestMapping(value = "product/list")
    public Result myProject(
            @RequestParam(value = "type", required = false, defaultValue = "1") final String type,
            @RequestParam(value = "userid", defaultValue = "") final String user_id,
            @RequestParam(value = "startdate", defaultValue = "") final String startdate,
            @RequestParam(value = "enddate", defaultValue = "") final String enddate,
            @RequestParam(value = "casename", defaultValue = "") final String casename,
            @RequestParam(value = "pagesize") final int page_size,
            @RequestParam(value = "pageIndex") final int page_index)
            throws IOException {
        return mattersService.myProject(new HashMap<String, String>() {
            {
                put("type", type);
                put("startdate", startdate);
                put("enddate", enddate);
                put("casename", casename);
                put("uid", String.valueOf(user_id));
                put("pagesize", String.valueOf(page_size));
                put("pageIndex", String.valueOf(page_index));
            }
        });
    }

    /**
     * 满意度评价
     *
     * @return Result
     */
    /*@RequestMapping(value = "product/myd")
    public Result projectMyd(@RequestParam(value = "prjid") final String prjid,
                             @RequestParam(value = "type") final int type,
                             @RequestParam(value = "mydcontent") final String mydcontent,
                             @RequestParam(value = "mydtype") final int mydtype)
            throws IOException {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("Prjid", prjid);
        jsonObject.put("type", type);
        jsonObject.put("mydcontent", mydcontent);
        jsonObject.put("mydtype", mydtype);
        System.out.println("\n");
        System.out.println("满意度评价参数：：" + jsonObject);
        System.out.println("\n");
        return mattersService.projectMyd(jsonObject);
    }*/
    @RequestMapping(value = "product/myd", method = POST)
    public Result projectMyd(@RequestBody MydEvaluation mydEvaluation) {
        if (org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getEvaluationGrade())) {
            return new Result(Result.FAILURE, "评价结果为空");
        }

        if (org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getEvaluationContent())) {
            return new Result(Result.FAILURE, "评价意见为空");
        }

        if (org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getCreateUserId())
                || org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getCreateUserName())) {
            return new Result(Result.FAILURE, "评价人信息为空");
        }

        if (org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getEvaluaTionType())
                || org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getEvaluaTionType())) {
            return new Result(Result.FAILURE, "评价类型为空");
        }

        if (org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getPrjGuid())
                || org.apache.commons.lang.StringUtils.isBlank(mydEvaluation.getPrjGuid())) {
            return new Result(Result.FAILURE, "编号为空");
        }

        return mattersService.projectMyd(mydEvaluation);
    }

    /**
     * 办件撤消
     *
     * @return Result
     */
    @RequestMapping(value = "product/undo", method = POST)
    public Result undoProject(
            @RequestParam(value = "Prjid") final String Prjid,
            @RequestParam(value = "type") final int type) throws IOException {
        JSONObject json = new JSONObject();
        json.put("Prjid", Prjid);
        json.put("type", type);
        return mattersService.undoProject(json);
    }

    /**
     * 办件详细信息
     *
     * @return Result
     */
    @RequestMapping(value = "product/detail/{prjid}/{type}")
    public Result projectDetail(@PathVariable("prjid") String prjid,
                                @PathVariable("type") String type) throws IOException {
        return mattersService.projectDetail(prjid, type);
    }

    /**
     * 获取管辖大队接口
     *
     * @return Result
     */
    @RequestMapping(value = "passport/gxdd", method = GET)
    public Result getGXDD() throws IOException {
        return mattersService.loadPassportYZDD();
    }

    /**
     * 获取运载物品接口
     *
     * @return Result
     */
    @RequestMapping(value = "passport/yzwp", method = GET)
    public Result truckReport() throws IOException {
        return mattersService.loadPassportYZWP();
    }

    /**
     * 保存线路
     */
    @RequestMapping(value = "line/save", method = POST)
    public Result submitline(@RequestBody JSONObject passport)
            throws IOException {
        passport.put("sendtype", "2");
        return mattersService.saveLine(passport);
    }

    /**
     * 需要货车通行证需要上传的文件
     */
    @Deprecated
    @RequestMapping(value = "passport/reqfiles", method = GET)
    public Result getRequireFiles() throws IOException {
        return mattersService.getPassportFiles();
    }

    /**
     * 加载具体事项申报所需材料列表
     *
     * @param caseId 办件ID
     * @param type   办件类型
     * @return Result
     * @throws IOException
     */
    @RequestMapping(value = "material/required", method = GET)
    public Result loadApplyMaterial(@RequestParam("caseId") String caseId, @RequestParam("type") String type) throws IOException {
        return mattersService.loadApplyMataer(caseId, type);
    }

    /**
     * 申报事项告知信息提交
     *
     * @param request HttpRequest
     * @return Result
     */
    @RequestMapping(value = "inform", method = POST)
    public Result reportMattersInform(HttpServletRequest request) {
        String userId = request.getParameter("userId");
        if (StringUtils.hasText(userId)) {
            return new Result(Result.FAILURE, "当前用户未登录");
        }
        String lawerId = request.getParameter("lawerId");
        return null;
    }

    /**
     * 上传货车临时通行证
     *
     * @param request MultipartHttpServletRequest
     * @return Result
     */
    @RequestMapping(value = "passport/photo/upload", method = POST)
    public Result uploadPassportPhoto(MultipartHttpServletRequest request) {
        String photoGuid = request.getParameter("guid");
        String userId = request.getParameter("userId");
        List<MultipartFile> mps = request.getFiles("photo");
        if (0 == mps.size()) {
            return new Result(Result.FAILURE, "请上传图片");
        }
        MultipartFile file = mps.get(0);
        try {
            return mattersService.savePassportPhoto(super.getLocalHostIP(),
                    userId, photoGuid, file);
        } catch (Exception ex) {
            ex.printStackTrace();
            return new Result(Result.FAILURE, "文件上传出错");
        }
    }

    /**
     * 保存通行证信息和线路信息
     */
    @RequestMapping(value = "passport/save", method = POST)
    public Result savePassportAll(HttpServletRequest request) {
        JSONObject passportInfo = new JSONObject();
        // 通行证信息
        passportInfo.put("sendtype", "1"); // 通行证信息
        passportInfo.put("txzGuid", request.getParameter("txzGuid"));
        passportInfo.put("projectGuid", request.getParameter("projectGuid"));
        // 申请单位或个人信息
        passportInfo.put("sqdw", request.getParameter("sqdw")); // 申请单位
        passportInfo.put("dh", request.getParameter("dh"));// 电话
        passportInfo.put("fzr", request.getParameter("fzr"));// 负责人
        passportInfo.put("itmGuid", request.getParameter("itmGuid"));// 运载物品
        passportInfo.put("gdszddd", request.getParameter("gdszddd"));// 线路起点管辖大队
        passportInfo.put("sqsj1", request.getParameter("sqsj1"));// 运行时段开始
        passportInfo.put("sqsj2", request.getParameter("sqsj2"));// 运行时段结束
        passportInfo.put("sqsy", request.getParameter("sqsy"));// 申请事由
        // 车辆相关信息
        passportInfo.put("cph", request.getParameter("cph")); // 车牌号
        passportInfo.put("jsyxm", request.getParameter("jsyxm")); // 驾驶员姓名
        passportInfo.put("jszh", request.getParameter("jszh")); // 驾驶证号
        // --------------线路信息------------------------
        JSONObject lineInfo = new JSONObject();
        lineInfo.put("sendtype", "2"); // -->通行证信息
        lineInfo.put("txzGuid", request.getParameter("txzGuid"));
        lineInfo.put("autoqd", request.getParameter("autoqd")); // 起点
        lineInfo.put("autotj", request.getParameter("autotj")); // 途径
        lineInfo.put("autozd", request.getParameter("autozd")); // 终点
        JSONObject caseInfo = new JSONObject();
        caseInfo.put("sendtype", "3");
        caseInfo.put("userguid", request.getParameter("userGuid"));
        caseInfo.put("projectguid", request.getParameter("projectGuid"));
        caseInfo.put("caseguid", request.getParameter("caseGuid"));
        caseInfo.put("unitGuid", request.getParameter("unitGuid"));
        // 通行证文件信息
        JSONObject filesInfo = new JSONObject();
        filesInfo.put("userId", request.getParameter("userId"));
        filesInfo.put("userGuid", request.getParameter("userGuid"));
        filesInfo.put("projectGuid", request.getParameter("projectGuid"));
        filesInfo.put("caseGuid", request.getParameter("caseGuid"));
        filesInfo.put("unitGuid", request.getParameter("unitGuid"));
        filesInfo.put("localHostIP", super.getLocalHostIP());// 本机IP
        String photoTypeGuids = request.getParameter("guid");
        if (null != photoTypeGuids) {
            String[] ids = photoTypeGuids.split("@");
            JSONArray photos = new JSONArray(3);
            for (String id : ids) {
                JSONObject photo = new JSONObject();
                photo.put("typeId", id);
                photo.put("photo", request.getParameter(id));
                photos.add(photo);
            }
            filesInfo.put("photos", photos);
        } else {
            return new Result(Result.FAILURE, "附件信息不正确");
        }
        try {
            return mattersService.reportVehicleTempPassportInfo(passportInfo,
                    lineInfo, caseInfo, filesInfo);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(Result.FAILURE, "上报失败");
        }
    }

    /**
     * 会见通知
     *
     * @param request
     * @return
     * @throws IOException
     */
    @RequestMapping(value = "lawyerMeet", method = POST)
    public Result lawyerMeetInform(HttpServletRequest request) throws IOException {
        JSONObject lawyerMeetInfo = new JSONObject();
        lawyerMeetInfo.put("LAWYERNO", request.getParameter("LAWYERNO"));
        lawyerMeetInfo.put("LAWYERXZ", request.getParameter("LAWYERXZ"));
        lawyerMeetInfo.put("XYRXM", request.getParameter("XYRXM"));
        lawyerMeetInfo.put("SFZH", request.getParameter("SFZH"));
        lawyerMeetInfo.put("AJBH", request.getParameter("AJBH"));
        lawyerMeetInfo.put("LAWYERXM", request.getParameter("LAWYERXM"));
        lawyerMeetInfo.put("LAWYERSZDQ", request.getParameter("LAWYERSZDQ"));
        lawyerMeetInfo.put("PHONE", request.getParameter("PHONE"));
        lawyerMeetInfo.put("LAWYERSWS", request.getParameter("LAWYERSWS"));
        lawyerMeetInfo.put("AY", "");
        lawyerMeetInfo.put("AJJD", request.getParameter("AJJD"));
        lawyerMeetInfo.put("sendtype", request.getParameter("sendtype"));
        return mattersService.loadLawyerMeetInfo(lawyerMeetInfo);
    }

    /**
     * 预约提交
     *
     * @param request
     * @return
     * @throws IOException
     */
    @RequestMapping(value = "appointmentSubmit", method = POST)
    public Result lawyerMeetAppointmentSub(HttpServletRequest request) throws IOException {
        JSONObject lawyerMeetInfo = new JSONObject();
        lawyerMeetInfo.put("dbid", request.getParameter("dbid"));
        lawyerMeetInfo.put("meetdate", request.getParameter("meetdate"));
        lawyerMeetInfo.put("meetsj", request.getParameter("meetsj"));
        lawyerMeetInfo.put("userguid", request.getParameter("userguid"));
        lawyerMeetInfo.put("caseguid", request.getParameter("caseguid"));
        lawyerMeetInfo.put("projectguid", request.getParameter("projectguid"));
        lawyerMeetInfo.put("jycs", request.getParameter("jycs"));
        lawyerMeetInfo.put("sendtype", request.getParameter("sendtype"));
        return mattersService.loadLawyerMeetAppointSub(lawyerMeetInfo);
    }

    /**
     * 律师材料上
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "photos/upload", method = POST)
    public Result uploadLawyerMeterial(MultipartHttpServletRequest request) {
        try {
            return mattersService.uploadLawyerMeterial(request);
        } catch (IOException e) {
            e.printStackTrace();
            return new Result(Result.FAILURE, "图片上传失败");
        }
    }

}